package com.healthshare.parse.news;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.palmedia.framework.parse.BaseParse;




/**
 * @author xudeliang
 * 三级分类解析
 */
public class TitleListParse extends BaseParse
{

//	/columlist {“id”:”112”,”title”:”女性”   ,"time":"2011-10-12:22:33","acticleid":"2002" }，
	
	public String page="";
	public ArrayList<TitleListItem> titleLisItems = new ArrayList<TitleListItem>();
	public TitleListParse()
	{
		
	}
	
	
	@Override
	public boolean Parse(byte[]data)
	{
		boolean ret = super.Parse(data);
		if(!ret)
		{
			return false;
		}
		if(JSON==parseType)
		{
			try 
			{
				JSONArray ja = jsonObject.getJSONArray("articlelist");
				int len = ja.length();
				for(int i=0;i<len;i++)
				{
					JSONObject iobject =ja.getJSONObject(i);
					String title = iobject.getString("title");
					String time = iobject.getString("time");
					String acticleid = iobject.getString("articleid");
					int paytype =0;
					if(iobject.has("paytype"))
					paytype=iobject.getInt("paytype");
					TitleListItem kv = new TitleListItem();
					kv.title = title;
					kv.time = time;
					kv.articleid = acticleid;
					kv.paytype=paytype;
					titleLisItems.add(kv);
				}
				return true;
			} 
			catch (JSONException e) 
			{
				e.printStackTrace();
			}
		}
		return false;
	}
	
	public class TitleListItem
	{
		public String title;
		public String time;
		public String articleid;
		public int paytype;//付费类型，0免费，1需要积分
		
	}
	
}
